package com.llxy.worker.service.impl;

import com.llxy.common.utils.StringUtils;
import com.llxy.worker.domain.HomemakingJob;
import com.llxy.worker.domain.SupportWorker;
import com.llxy.worker.dto.HomemakingDTO;
import com.llxy.worker.dto.SupportWorkerDTO;
import com.llxy.worker.mapper.HomemakingJobMapper;
import com.llxy.worker.mapper.SupportWorkerMapper;
import com.llxy.worker.service.SupportWorkerService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.llxy.worker.mapper.HomemakingMapper;
import com.llxy.worker.domain.Homemaking;
import com.llxy.worker.service.HomemakingService;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class HomemakingServiceImpl implements HomemakingService{

    @Resource
    private HomemakingMapper homemakingMapper;

    @Autowired
    private SupportWorkerService supportWorkerService;

    @Autowired
    private HomemakingJobMapper homemakingJobMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return homemakingMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Homemaking record) {
        return homemakingMapper.insert(record);
    }

    @Override
    public int insertSelective(Homemaking record) {
        return homemakingMapper.insertSelective(record);
    }

    @Override
    public Homemaking selectByPrimaryKey(Integer id) {
        return homemakingMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Homemaking record) {
        return homemakingMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Homemaking record) {
        return homemakingMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Homemaking> selectHomemakingList(Homemaking homemaking) {
        return homemakingMapper.selectHomemakingList(homemaking);
    }

    @Override
    public List<SupportWorkerDTO> selectSupportWorkerInfo(Integer id,String type) {
        SupportWorker supportWorker = new SupportWorker();
        supportWorker.setHomemakingId(id);
        if (StringUtils.isNotBlank(type)){
            supportWorker.setType(Integer.valueOf(type));
        }
        return supportWorkerService.selectSupportWorkerList(supportWorker);
    }

    @Override
    public List<HomemakingJob> selectJobInfo(Integer id, String type) {
        HomemakingJob homemakingJob = new HomemakingJob();
        homemakingJob.setHomemakingId(id);
        if (StringUtils.isNotBlank(type)){
            homemakingJob.setType(type);
        }
        return homemakingJobMapper.selectHomemakingJobList(homemakingJob);
    }

}
